from allpairspy import AllPairs

from api_py.enums.cookie import Cookie
from api_py.generate_case.template import template_case
from api_py.utils.file_sys import write_json

max_consults = [
    {"value": "", "description": "最大咨询人数参数为空"},
    {"value": "0", "description": "最大咨询人数为0"},
    {"value": "10", "description": "最大咨询人数为10"},
    {"value": "100000000000000000000", "description": "咨询人数越界"},
    {"value": "abc", "description": "非法参数"},
]

cookie = [
    {"value": Cookie.COUNSELOR_COOKIE.value, "description": "咨询师登录"},
    {"value": Cookie.SUPERVISOR_COOKIE.value, "description": "督导登录"},
]

def case21_user_maxconsults(api_type):
    json_result = {}
    parameters = [max_consults, cookie]

    for i, pairs in enumerate(AllPairs(parameters)):
        case = template_case()
        request = case["request"]

        # 设置请求体参数
        request["body"]["maxConsults"] = pairs[0]
        # 设置请求头cookie
        request["headers"]["Cookie"] = pairs[1]

        json_result[i] = case

    write_json(api_type.value[0]["file_name"], json_result)
